package com.java3_2;
public class Test {
}
class MyThread1 extends Thread {
    @Override
    public void run() {
        for (int i = 1; i <= 10; i += 2) {
            System.out.println(Thread.currentThread().getName() + "  " + i);
        }
    }
}
class MyThread2 extends Thread {
    private boolean flag = true;
    @Override
    public void run() {
        for (int i = 2; i <= 10 && flag; i += 2) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(Thread.currentThread().getName() + "  " + i);
        }
    }public void setFlag(boolean flag) {
        this.flag = flag;
    }
}
